package cn.zdq.picture_lib.activity

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.viewpager2.widget.ViewPager2
import cn.zdq.picture_lib.R
import cn.zdq.picture_lib.adapter.ViewPager2Adapter
import cn.zdq.picture_lib.config.PictureConfig
import cn.zdq.picture_lib.model.LocalMedia

/**
 *
 * @Description:
 * @Author: zhoudequn
 * @CreateDate: 2021/10/13 14:20
 */
class PicturePreviewActivity : AppCompatActivity() {
    private var cacheData: MutableList<LocalMedia> = mutableListOf()

    override fun onCreate(bundle: Bundle?) {
        super.onCreate(bundle)
        setContentView(R.layout.activity_picture_preview)
        if (intent.getParcelableArrayListExtra<LocalMedia>(PictureConfig.EXTRA_SELECT_LIST) != null) {
            val fromDatas =
                intent.getParcelableArrayListExtra<LocalMedia>(PictureConfig.EXTRA_SELECT_LIST)
            if (fromDatas != null) {
                cacheData.addAll(fromDatas)
            }
        }
        var viewPager2 = findViewById<ViewPager2>(R.id.viewpager2)
        val viewPager2Adapter = ViewPager2Adapter(cacheData)
        viewPager2.adapter = viewPager2Adapter
    }
}